//
//  Texture.h
//  Ray Tracer
//
//  Created by Kaila, Ashish on 3/23/13.
//  Copyright (c) 2013 Kaila, Ashish. All rights reserved.
//

#ifndef __Ray_Tracer__Texture__
#define __Ray_Tracer__Texture__

#include <memory>
#include "Material.h"
#include "ITextureMapper.h"
#include "../Utils/util.h"

class TextureMaterial : public Material
{
public:
    TextureMaterial(char* fileName,
                    Colour shadowAmbientColour,
                    double specularExp,
                    double diffuseReflectivityFactor,
                    double specularReflectivityFactor,
                    double refractiveIndex);
    
    ~TextureMaterial();
    
    unsigned long getWidth() const;
    unsigned long getHeight() const;
    virtual Colour getColour(ColourType type, const Intersection& intersection, bool inShadow) const;
    
private:
    
    // Returns a clamped colour at a specified location
    Colour getColour(int i, int j) const;
    
private:

    unsigned long int width;
    long int height;
    
#ifdef __APPLE__
    std::auto_ptr<unsigned char> r;
    std::auto_ptr<unsigned char> g;
    std::auto_ptr<unsigned char> b;
#else
    unsigned char* r;
    unsigned char* g;
    unsigned char* b;
#endif
    
    const Colour _shadowAmbientColour;
};

#endif /* defined(__Ray_Tracer__Texture__) */
